﻿using System;
using Teigha.Core;
using Teigha.TD;

namespace App
{
	internal class TeighaServices
	{
		private TeighaServices()
		{
		}

		public bool InitTeighaService(bool bAttach)
		{
			if (bAttach)
			{
				this.m_TeighaExSysServices = new ExSystemServices();
				TD_Db.odInitialize(this.m_TeighaExSysServices);
				this.m_HostAppServices = new ExHostAppServices();
			}
			else
			{
				try
				{
					this.m_TeighaExSysServices.Dispose();
					this.m_HostAppServices.Dispose();
				}
				catch (Exception)
				{
				}
				TD_Db.odUninitialize();
			}
			return true;
		}

		public static TeighaServices TeighaServicesInstance
		{
			get
			{
				if (TeighaServices.m_appServices == null)
				{
					TeighaServices.m_appServices = new TeighaServices();
				}
				return TeighaServices.m_appServices;
			}
		}

		public ExHostAppServices HostAppServices
		{
			get
			{
				return this.m_HostAppServices;
			}
		}

		private static TeighaServices m_appServices;

		private ExSystemServices m_TeighaExSysServices;

		private ExHostAppServices m_HostAppServices;
	}
}
